home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 June / EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso / earcd / comm2 / mmesec10.lha / MM / Rexx / MM_EstadisEcos.rexx < prev    next >
OS/2 REXX Batch file  |  1996-05-14  |  26KB  |  820 lines

  1. /* 
  2.  
  3.  
  4.                             EstadisEcos.rexx
  5.                     (c) Ferran Delriu - 07-10-1993
  6.                                v1.0 a v2.2     
  7.  
  8.                            MM_EstadisEcos.rexx
  9.                     (c) Ferran Delriu - 15-05-1996
  10.  
  11.                    Amiga-Penedes BBS 34-3-817-24-40    
  12.                            2:343/119.0@fidonet          
  13.                            39:190/1.0@amiganet          
  14.                         E-Mail fdelriu@redestb.es       
  15.  
  16.              $VER: MM_EstadisEcos.rexx v1.0 by Ferran Delriu
  17. */
  18.  
  19. ver="MM_EstadisEcos.rexx v1.0 by Ferran Delriu"
  20.  
  21. signal on break_c
  22. signal on halt
  23. signal on syntax
  24. signal on ioerr
  25.  
  26. options results
  27. address command
  28.  
  29.  
  30. if ~show('l','rexxmathlib.library') then do
  31.    call addlib('rexxmathlib.library',0,-30)
  32.    end
  33. if ~show('l','rexxsupport.library') then do
  34.    call addlib('rexxsupport.library',0,-30)
  35.    end
  36. if ~show('l','rexxarplib.library') then do
  37.    call addlib('rexxarplib.library',0,-30)
  38.    end
  39.  
  40.  
  41.  
  42. /*activa MAILMANAGER si no esta activo*/
  43. address command('waitforport MAILMANAGER')
  44. if rc>0 then do
  45.   address command('run <>NIL: mm:bin/mm')
  46.   address command('waitforport MAILMANAGER')
  47.   if rc>0 then do
  48.     say 'Hay algun problema con el MAILER.. SORRY.'
  49.     exit
  50.   end
  51. end
  52.  
  53.  
  54. /*inicia reloj*/
  55. r=time('r')
  56.  
  57. address 'MAILMANAGER'
  58. MM.LogLevel=2
  59. CALL WriteLog('MM_EstadisEcos.rexx - Entrada')
  60. address command
  61.  
  62.  
  63. /*asignacion variables*/
  64. MesTexto="JanFebMarAprMayJunJulAugSepOctNovDec"
  65. HoraTexto.1="00:00-03:00"
  66. HoraTexto.2="03:00-06:00"
  67. HoraTexto.3="06:00-09:00"
  68. HoraTexto.4="09:00-12:00"
  69. HoraTexto.5="12:00-15:00"
  70. HoraTexto.6="15:00-18:00"
  71. HoraTexto.7="18:00-21:00"
  72. HoraTexto.8="21:00-00:00"
  73.  
  74. log=""
  75. /*Lee fichero EstadisEcos.cfg*/
  76. Tag.="";Ecos=0;totalcfg=0
  77. if open('source','MM:config/MM_EstadisEcos.cfg') then do
  78.   do while eof('source')~=1
  79.     linea=readln('source')
  80.     do forever
  81.       pos=lastpos(d2c(9),linea)
  82.       if pos>0 then do
  83.         linea=overlay(' ',linea,pos)
  84.       end
  85.       else do
  86.         leave
  87.       end
  88.     end
  89.     totalcfg=totalcfg+1
  90.     totalcfg.totalcfg=linea
  91.     if upper(word(linea,1))="#AREA" then do
  92.       Ecos=Ecos+1
  93.       Tag.Ecos=word(linea,2)
  94.       leng.Ecos=word(linea,3)
  95.       if leng.Ecos~="ESP" & leng.Ecos~="ING" then do
  96.         leng.Ecos="ING"
  97.       end
  98.       TopeDias.Ecos=word(linea,4)
  99.       if TopeDias.Ecos<=0 | datatype(TopeDias.Ecos)~="NUM" then do
  100.         TopeDias.Ecos=100
  101.         fallo="Error! en #AREA "||Tag.Ecos||" - Asigno 100 dias por defecto"
  102.         call fallos
  103.       end
  104.       Control.Ecos=subword(linea,5)
  105.     end
  106.     if upper(word(linea,1))="#BANNER1" then banner1=subword(linea,2)
  107.     if upper(word(linea,1))="#BANNER2" then banner2=subword(linea,2)
  108.     if upper(word(linea,1))="#BANNER3" then banner3=subword(linea,2)
  109.     if upper(word(linea,1))="#LOG" then do
  110.       pathlog=subword(linea,2)
  111.       if words(pathlog)=0 then pathlog="ram:MM_EstadisEcos.log"
  112.       if exists(pathlog)=0 then do
  113.         if open('source1',pathlog,'W') then do
  114.           b=writeln('source1',date('e')||' '||time()||' Creacion Fichero Log')
  115.         call close 'source1'
  116.         end
  117.       end
  118.       if exists(pathlog)=1 then do
  119.         log=date('e')||" "||time()||" MM_EstadisEcos.rexx - Entrada"
  120.         call logs
  121.       end
  122.     end
  123.   end
  124. call close 'source'
  125. end
  126. totalcfg=totalcfg-1
  127.  
  128.  
  129.  
  130.  
  131. encuentra=0
  132.  
  133. /*lee ecos y procesa*/
  134. do x=1 to Ecos
  135.   address 'MAILMANAGER'
  136.   CALL WriteLog(' * 'Tag.x ' - Analizo')
  137.   log=date('e')||" "||time()||"  * "||Tag.x||" - Analizo"
  138.   call logs
  139.   MM_SearchMsgs Tag.x 'NUM' '#?' '#?' '#?' 
  140.   if RC=0 then do
  141.     do xx=0 FOR NUM.COUNT
  142.       MM_ReadMsg Tag.x NUM.xx MSG
  143.       if RC=0 then do
  144.         do i=0 for MSG.HEAD.COUNT
  145.           if pos('MSGID:',MSG.HEAD.i)>0 then do
  146.             ControlUltimo=substr(MSG.HEAD.i,2)
  147.             if Control.x=substr(MSG.HEAD.i,2) then do
  148.               encuentra=1
  149.             end
  150.           end
  151.         end
  152.       end
  153.     end
  154.  
  155.     /*no ha encontrado LineaControl, procesa estadistica*/
  156.     if encuentra=0 & NUM.COUNT>0 then do
  157.       /*memoriza Control ultimo mensaje*/
  158.       Control.x=ControlUltimo
  159.  
  160.       address 'MAILMANAGER'
  161.       CALL WriteLog(' * 'Tag.x ' - Proceso')
  162.       log=date('e')||" "||time()||"  * "||Tag.x||" - Proceso"
  163.       call logs
  164.  
  165.       /*Lectura Ecos y Analisis*/
  166.       PrimeraFecha=date('b')
  167.       De.="";Para.="";Tema.="";Fecha.="";Hora.=0;Bytes.=0;Origin.="";Quotes.=""
  168.       QuotesNom.=""
  169.       FueraDeFecha=0
  170.       MsgTotal=0
  171.  
  172.       address 'MAILMANAGER'
  173.       MM_SearchMsgs Tag.x 'NUM' '#?' '#?' '#?' 
  174.       if RC=0 then do
  175.         do z=0 for NUM.COUNT
  176.           MM_ReadMsg Tag.x NUM.z MSG
  177.           if RC=0 then do
  178.             Dia=word(MSG.DATE,1)
  179.             Mes=word(MSG.DATE,2)
  180.             Ano=word(MSG.DATE,3)
  181.             hora=left(word(MSG.DATE,4),2)
  182.  
  183.             /*Primero investiga fecha si es antigua o futura*/
  184.             MsgTotal=MsgTotal+1
  185.             pos=pos(Mes,MesTexto);pos=pos%3+1
  186.             if Dia<1 | Dia>31 then Dia=1
  187.             if pos=0 then pos=1
  188.             if Ano<92 then Ano=92
  189.             Fecha.MsgTotal="19"||Ano||right(pos,2,0)||right(Dia,2,0)
  190.             if date('b')-date('b',Fecha.MsgTotal,'S')>TopeDias.x | date('b',Fecha.MsgTotal,'S')>date('b') then do
  191.               FueraDeFecha=FueraDeFecha+1
  192.               MsgTotal=MsgTotal-1
  193.             end
  194.             else do
  195.               /*Si fecha es razonable, sigue con el mensaje*/
  196.               de.msgtotal=MSG.FROM
  197.               para.msgtotal=MSG.TO
  198.               tema.msgtotal=MSG.SUBJ
  199.               if date('b',Fecha.MsgTotal,'S')<PrimeraFecha then do
  200.                 PrimeraFecha=date('b',Fecha.MsgTotal,'S')
  201.                 PrimeraFechaE=Fecha.MsgTotal
  202.               end
  203.               Hora.MsgTotal=Hora
  204.               quote=0;noquote=0
  205.               if msg.text.count=0 then MSG.TEXT.COUNT=1
  206.               do b=0 for MSG.TEXT.COUNT-1
  207.                 /*recuento de bytes*/
  208.                 Bytes.MsgTotal=Bytes.MsgTotal+length(MSG.TEXT.b)
  209.                 /*recuento de quotes*/
  210.                 If Index(left(MSG.TEXT.b,5),'>')~=0 then do
  211.                   quote=quote+length(MSG.TEXT.b)
  212.                 end
  213.                 else do
  214.                   noquote=noquote+length(MSG.TEXT.b)
  215.                 end
  216.               end
  217.               if quote+noquote>0 then do
  218.                 Quotes.MsgTotal=quote*100/(quote+noquote)
  219.               end
  220.               else do
  221.                 Quotes.MsgTotal=0
  222.               end
  223.               QuotesNom.MsgTotal=De.MsgTotal
  224.               Origin.MsgTotal=MSG.FROMADDR
  225.             end
  226.           end
  227.         end z
  228.       end
  229.  
  230.       TotalDias=date('b')-PrimeraFecha
  231.  
  232.       call idioma
  233.  
  234.       log=date('e')||" "||time()||"    "||left(idioma.3,25,'.')||": "||MsgTotal
  235.       call logs
  236.       log=date('e')||" "||time()||"    "||left(idioma.4,25,'.')||": "||trunc(MsgTotal/TotalDias,2)
  237.       call logs
  238.       log=date('e')||" "||time()||"    "||left(idioma.5,25,'.')||": "||TotalDias||" - "||idioma.6||" "||date('e',PrimeraFechaE,'S')||" "||idioma.7||" "||date('e')
  239.       call logs
  240.       log=date('e')||" "||time()||"    "||left(idioma.8,25,'.')||": "||FueraDeFecha||" (Max. "||TopeDias.x||" "||idioma.34||")"
  241.       call logs
  242.       log=date('e')||" "||time()||"    "||left(' ',25,' ')||"  ["||idioma.9||"]"
  243.       call logs
  244.  
  245.       address command
  246.       if open('source','ram:Mensaje.txt','W') then do
  247.         b=writeln('source',copies('=',60))
  248.         b=writeln('source',center(idioma.1' ['Tag.x']',60))
  249.         b=writeln('source',center(idioma.2' 'date()' - 'time(),60))
  250.         b=writeln('source',copies('-',60))
  251.         b=writeln('source',center(banner1,60))
  252.         b=writeln('source',center(banner2,60))
  253.         b=writeln('source',center(banner3,60))
  254.         b=writeln('source',copies('=',60))
  255.         b=writeln('source',center(ver,60))
  256.         b=writeln('source',center('2:343/119.0@fidonet 39:190/1.0@amiganet',60))
  257.         b=writeln('source',copies('=',60))
  258.         b=writeln('source','')
  259.         b=writeln('source','')
  260.         b=writeln('source',left(idioma.3,25,'.')': 'MsgTotal)
  261.         b=writeln('source',left(idioma.4,25,'.')': 'trunc(MsgTotal/TotalDias,2))
  262.         b=writeln('source',left(idioma.5,25,'.')': 'TotalDias' - 'idioma.6' 'date('e',PrimeraFechaE,'S')' 'idioma.7' 'date('e'))
  263.         b=writeln('source',left(idioma.8,25,'.')': 'FueraDeFecha' (Max. 'TopeDias.x' 'idioma.34')')
  264.         b=writeln('source',left(' ',25,' ')'  ['idioma.9']')
  265.       call close 'source'
  266.       end
  267.  
  268.       veces=1;BytesTotales=0
  269.         /*Calculo MAS ESCRIBEN*/
  270.         address 'MAILMANAGER'
  271.         CALL WriteLog('   / Mas Escriben')
  272.         address command
  273.         log=date('e')||" "||time()||"    / Mas Escriben"
  274.         call logs
  275.         do i= 1 to MsgTotal
  276.           if De.i~="" then do
  277.             veces=1;bytes=bytes.i
  278.             do y=i+1 to MsgTotal
  279.               if De.i=De.y then do
  280.                 veces=veces+1
  281.                 bytes=bytes+bytes.y
  282.                 de.y=""
  283.               end
  284.             end y
  285.             De.i=right(veces,3)||" "||De.i||" "bytes
  286.             BytesTotales=BytesTotales+bytes
  287.           end  
  288.         end i
  289.         /*graba en ram: para ordenacion*/
  290.         if open('source','ram:Temp0.txt','W') then do
  291.           do i = 1 to MsgTotal
  292.             b=writeln('source',De.i)
  293.           end
  294.         call close 'source'
  295.         end
  296.         'c:sort ram:Temp0.txt ram:Temp1.txt'
  297.         /*lee de ram: ya ordenado*/
  298.         if open('source','Ram:Temp1.txt') then do
  299.           do i = MsgTotal to 1 by -1
  300.             De.i=readln('source')
  301.           end
  302.         call close 'source'
  303.         end
  304.         if open('source','ram:Mensaje.txt','A') then do
  305.           b=writeln('source','')
  306.           b=writeln('source','')
  307.           b=writeln('source',copies('=',60))
  308.           b=writeln('source',center(idioma.10' ['Tag.x']',60))
  309.           b=writeln('source',copies('=',60))
  310.           b=writeln('source',' 'left(idioma.11,25)||left(idioma.12,14)||left(idioma.13,10)||idioma.14)
  311.           b=writeln('source',copies('-',60))
  312.           do i=1 to 10
  313.             if De.i~="" then do
  314.               veces=word(De.i,1)
  315.               bytes=word(De.i,words(De.i))
  316.               De.i=delword(De.i,1,1)
  317.               De.i=delword(De.i,words(De.i))
  318.               j=""
  319.               do o=1 to words(De.i)
  320.                 j=j||word(De.i,o)||" "
  321.               end
  322.               De.i=j
  323.               b=writeln('source',' '||left(De.i,24,'.')' 'right(veces,3)' 'right(trunc(int(veces*100/MsgTotal+.5)),3)'% 'right(bytes,8)' 'right(trunc(int(bytes*100/BytesTotales+.5)),3)'% 'right(Bytes%veces,8))
  324.             end
  325.           end
  326.           b=writeln('source',copies('=',60))
  327.         call close 'source'
  328.         end
  329.  
  330.  
  331.       veces=1
  332.         /*Calculo MAS RECIBEN*/
  333.         address 'MAILMANAGER'
  334.         CALL WriteLog('   | Mas Reciben')
  335.         address command
  336.         log=date('e')||" "||time()||"    | Mas Reciben"
  337.         call logs
  338.         do i= 1 to MsgTotal
  339.           if Para.i~="" then do
  340.             veces=1
  341.             do y=i+1 to MsgTotal
  342.               if Para.i=Para.y then do
  343.                 veces=veces+1
  344.                 Para.y=""
  345.               end
  346.             end y
  347.             Para.i=right(veces,3)||" "||Para.i
  348.           end  
  349.         end i
  350.         /*graba en ram: para ordenacion*/
  351.         if open('source','ram:Temp0.txt','W') then do
  352.           do i = 1 to MsgTotal
  353.             b=writeln('source',Para.i)
  354.           end
  355.         call close 'source'
  356.         end
  357.         'c:sort ram:Temp0.txt ram:Temp1.txt'
  358.         /*lee de ram: ya ordenado*/
  359.         if open('source','Ram:Temp1.txt') then do
  360.           do i = MsgTotal to 1 by -1
  361.             Para.i=readln('source')
  362.           end
  363.         call close 'source'
  364.         end
  365.         if open('source','ram:Mensaje.txt','A') then do
  366.           b=writeln('source','')
  367.           b=writeln('source','')
  368.           b=writeln('source',copies('=',60))
  369.           b=writeln('source',center(idioma.15' ['Tag.x']',60))
  370.           b=writeln('source',copies('=',60))
  371.           b=writeln('source','      'left(idioma.11,40)||idioma.12)
  372.           b=writeln('source',copies('-',60))
  373.           do i=1 to 10
  374.             if Para.i~="" then do
  375.               veces=word(Para.i,1)
  376.               Para.i=delword(Para.i,1,1)
  377.               j=""
  378.               do o=1 to words(Para.i)
  379.                 j=j||word(Para.i,o)||" "
  380.               end
  381.               Para.i=j
  382.               b=writeln('source',copies(' ',6)||left(Para.i,38,'.')' 'right(veces,3)' 'right(trunc(int(veces*100/MsgTotal+.5)),3)'% ')
  383.             end
  384.           end
  385.           b=writeln('source',copies('=',60))
  386.         call close 'source'
  387.         end
  388.     
  389.  
  390.   
  391.       veces=1
  392.         /*Calculo TEMAS*/
  393.         address 'MAILMANAGER'
  394.         CALL WriteLog('   | Mas Temas')
  395.         address command
  396.         log=date('e')||" "||time()||"    | Mas Temas"
  397.         call logs
  398.         do i= 1 to MsgTotal
  399.           if Tema.i~="" then do
  400.             veces=1
  401.             do y=i+1 to MsgTotal
  402.               if Tema.i=Tema.y then do
  403.                 veces=veces+1
  404.                 Tema.y=""
  405.               end
  406.             end y
  407.             Tema.i=right(veces,3)||" "||Tema.i
  408.           end  
  409.         end i
  410.         /*graba en ram: para ordenacion*/
  411.         if open('source','ram:Temp0.txt','W') then do
  412.           do i = 1 to MsgTotal
  413.             b=writeln('source',Tema.i)
  414.           end
  415.         call close 'source'
  416.         end
  417.         'c:sort ram:Temp0.txt ram:Temp1.txt'
  418.         /*lee de ram: ya ordenado*/
  419.         if open('source','Ram:Temp1.txt') then do
  420.           do i = MsgTotal to 1 by -1
  421.             Tema.i=readln('source')
  422.           end
  423.         call close 'source'
  424.         end
  425.         if open('source','ram:Mensaje.txt','A') then do
  426.           b=writeln('source','')
  427.           b=writeln('source','')
  428.           b=writeln('source',copies('=',60))
  429.           b=writeln('source',center(idioma.16' ['Tag.x']',60))
  430.           b=writeln('source',copies('=',60))
  431.           b=writeln('source','      'left(idioma.17,39)||idioma.12)
  432.           b=writeln('source',copies('-',60))
  433.           do i=1 to 5
  434.             if Tema.i~="" then do
  435.               veces=word(Tema.i,1)
  436.               Tema.i=delword(Tema.i,1,1)
  437.               j=""
  438.               do o=1 to words(Tema.i)
  439.                 j=j||word(Tema.i,o)||" "
  440.               end
  441.               Tema.i=j
  442.               b=writeln('source',copies(' ',6)||left(Tema.i,38,'.')' 'right(veces,3)' 'right(trunc(int(veces*100/MsgTotal+.5)),3)'% ')
  443.             end
  444.           end
  445.           b=writeln('source',copies('=',60))
  446.         call close 'source'
  447.         end
  448.     
  449.  
  450.  
  451.  
  452.         /*calcula QUOTES*/
  453.       veces=1
  454.         /*Calculo MAS QUOTES*/
  455.         address 'MAILMANAGER'
  456.         CALL WriteLog('   | Mas Quotes')
  457.         address command
  458.         log=date('e')||" "||time()||"    | Mas Quotes"
  459.         call logs
  460.         ii=0
  461.         quotestot.=""
  462.         do i= 1 to MsgTotal
  463.           if words(quotesnom.i)>0 then do
  464.             veces=1;porcen=quotes.i
  465.             do y=i+1 to MsgTotal
  466.               if quotesnom.i=quotesnom.y then do
  467.                 veces=veces+1
  468.                 porcen=porcen+quotes.y
  469.                 quotesnom.y=""
  470.               end
  471.             end y
  472.             ii=ii+1
  473.             quotestot.ii=right(trunc(int(porcen/veces)),3)||" "||quotesnom.i
  474.           end
  475.         end i
  476.         /*graba en ram: para ordenacion*/
  477.         if open('source','ram:Temp0.txt','W') then do
  478.           do i = 1 to ii
  479.             b=writeln('source',quotestot.i)
  480.           end
  481.         call close 'source'
  482.         end
  483.         'c:sort ram:Temp0.txt ram:Temp1.txt'
  484.         /*lee de ram: ya ordenado*/
  485.         if open('source','Ram:Temp1.txt') then do
  486.           do i = ii to 1 by -1
  487.             quotestot.i=readln('source')
  488.           end
  489.         call close 'source'
  490.         end
  491.         if open('source','ram:Mensaje.txt','A') then do
  492.           b=writeln('source','')
  493.           b=writeln('source','')
  494.           b=writeln('source',copies('=',60))
  495.           b=writeln('source',center(idioma.18' ['Tag.x']',60))
  496.           b=writeln('source',copies('=',60))
  497.           b=writeln('source','      'left(idioma.11,36)'% 'idioma.19)
  498.           b=writeln('source',copies('-',60))
  499.           do i=1 to 10
  500.             if quotestot.i~="" then do
  501.               veces=word(quotestot.i,1)
  502.               quotestot.i=delword(quotestot.i,1,1)
  503.               j=""
  504.               do o=1 to words(quotestot.i)
  505.                 j=j||word(quotestot.i,o)||" "
  506.               end
  507.               quotestot.i=j
  508.               b=writeln('source',copies(' ',6)||left(quotestot.i,38,'.')' 'right(trunc(int(veces)),3)'% ')
  509.             end
  510.           end
  511.           b=writeln('source',copies('=',60))
  512.         call close 'source'
  513.         end
  514.  
  515.  
  516.  
  517.       /*HORAS en que se escriben mas mensajes*/
  518.         Horas.=0
  519.         address 'MAILMANAGER'
  520.         CALL WriteLog('   | Mas Horas')
  521.         address command
  522.         log=date('e')||" "||time()||"    | Mas Horas"
  523.         call logs
  524.         do i=1 to MsgTotal
  525.           Hora.i=compress(hora.i)
  526.           if Hora.i>=0 & Hora.i<3 then Horas.1=Horas.1+1
  527.           if Hora.i>=3 & Hora.i<6 then Horas.2=Horas.2+1
  528.           if Hora.i>=6 & Hora.i<9 then Horas.3=Horas.3+1
  529.           if Hora.i>=9 & Hora.i<12 then Horas.4=Horas.4+1
  530.           if Hora.i>=12 & Hora.i<15 then Horas.5=Horas.5+1
  531.           if Hora.i>=15 & Hora.i<18 then Horas.6=Horas.6+1
  532.           if Hora.i>=18 & Hora.i<21 then Horas.7=Horas.7+1
  533.           if Hora.i>=21 & Hora.i<24 then Horas.8=Horas.8+1
  534.         end
  535.         if open('source','ram:Mensaje.txt','A') then do
  536.           b=writeln('source','')
  537.           b=writeln('source','')
  538.           b=writeln('source',copies('=',60))
  539.           b=writeln('source',center(idioma.20' ['Tag.x']',60))
  540.           b=writeln('source',copies('=',60))
  541.           max=0;hortot=0;porcien.=0
  542.           do i=1 to 8
  543.             if horas.i>max then max=horas.i
  544.             hortot=hortot+horas.i
  545.           end
  546.           do i=1 to 8
  547.             porcien.i=trunc(int(horas.i*100/max+.5))
  548.           end
  549.           do i=1 to 8
  550.             por=trunc(int(horas.i*100/hortot+.5))
  551.             b=writeln('source',copies(' ',6)||HoraTexto.i' 'right(por,3)'% 'copies('*',trunc(int(30*porcien.i/100+.5))))
  552.           end
  553.           b=writeln('source',copies('=',60))
  554.         call close 'source'
  555.         end
  556.     
  557.   
  558.  
  559.   
  560.       /*Dias de la SEMANA en que se escriben mas mensajes*/
  561.         Semana.=0
  562.         address 'MAILMANAGER'
  563.         CALL WriteLog('   | Mas Semanas')
  564.         address command
  565.         log=date('e')||" "||time()||"    | Mas Semanas"
  566.         call logs
  567.         do i=1 to MsgTotal
  568.           Semana=date('w',Fecha.i,'S')
  569.           if semana="Monday" then Semana.1=Semana.1+1
  570.           if semana="Tuesday" then Semana.2=Semana.2+1
  571.           if semana="Wednesday" then Semana.3=Semana.3+1
  572.           if semana="Thursday" then Semana.4=Semana.4+1
  573.           if semana="Friday" then Semana.5=Semana.5+1
  574.           if semana="Saturday" then Semana.6=Semana.6+1
  575.           if semana="Sunday" then Semana.7=Semana.7+1
  576.         end
  577.         if open('source','ram:Mensaje.txt','A') then do
  578.           b=writeln('source','')
  579.           b=writeln('source','')
  580.           b=writeln('source',copies('=',60))
  581.           b=writeln('source',center(idioma.21' ['Tag.x']',60))
  582.           b=writeln('source',copies('=',60))
  583.           max=0;semtot=0;porcien.=0
  584.           do i=1 to 7
  585.             if semana.i>max then max=semana.i
  586.             semtot=semtot+semana.i
  587.           end
  588.           do i=1 to 7
  589.             porcien.i=trunc(int(semana.i*100/max+.5))
  590.           end
  591.           do i=1 to 7
  592.             por=trunc(int(semana.i*100/semtot+.5))
  593.             ii=21+i
  594.             b=writeln('source',copies(' ',6)||left(idioma.ii,11,'.')' 'right(por,3)'% 'copies('*',trunc(int(30*porcien.i/100+.5))))
  595.           end
  596.           b=writeln('source',copies('=',60))
  597.         call close 'source'
  598.         end
  599.  
  600.  
  601.  
  602.         /*BBS que mas participan*/
  603.         address 'MAILMANAGER'
  604.         CALL WriteLog('   | BBS que Mas Participan')
  605.         address command
  606.         log=date('e')||" "||time()||"    | BBS que Mas Participan"
  607.         call logs
  608.         do i=0 to MsgTotal
  609.           /*elimina de la direccion a partir del punto hasta el final*/
  610.           PosOri=pos('.',origin.i)
  611.           if PosOri>0 then do
  612.             Origin.i=left(origin.i,PosOri-1)
  613.           end
  614.           else do
  615.             /*si no hay punto mira si hay domain y borra hasta el final*/
  616.             PosOri=pos('@',origin.i)
  617.             if PosOri>0 then do
  618.               Origin.i=left(origin.i,PosOri-1)
  619.             end
  620.           end
  621.           /*pone direccion y bytes mensaje en la misma linea*/
  622.           Origin.i=Origin.i||" "||bytes.i
  623.         end
  624.  
  625.   
  626.         /*graba en ram: para ordenacion*/
  627.         if open('source','ram:Temp0.txt','W') then do
  628.           do i = 1 to MsgTotal
  629.             b=writeln('source',Origin.i)
  630.           end
  631.         call close 'source'
  632.         end
  633.         'c:sort ram:Temp0.txt ram:Temp1.txt'
  634.         /*lee de ram: ya ordenado*/
  635.         if open('source','Ram:Temp1.txt') then do
  636.           do i = 1 to MsgTotal
  637.             Ori.i=readln('source')
  638.           end
  639.         call close 'source'
  640.         end
  641.   
  642.         OriNodo.="";OriBytes.=0;OriNum.=0
  643.         Oris=1
  644.         /*procesa porcentajes bbs que mas llaman*/
  645.         OriNodo.oris=word(ori.1,1)
  646.         OriBytes.oris=word(ori.1,2)
  647.         OriNum.oris=1
  648.         do i=1 to MsgTotal-1
  649.           ii=i+1
  650.           if word(ori.i,1)=word(ori.ii,1) then do
  651.             OriBytes.oris=OriBytes.oris+word(ori.ii,2)
  652.             OriNum.oris=OriNum.oris+1
  653.           end
  654.           else do
  655.             Oris=Oris+1
  656.             OriNodo.oris=word(ori.ii,1)
  657.             OriBytes.oris=word(ori.ii,2)
  658.             OriNum.oris=1
  659.           end
  660.         end
  661.   
  662.         OriBytes=0
  663.         /*suma bytes totales*/
  664.         do i=1 to oris
  665.           /*say OriNodo.i OriBytes.i OriNum.i*/
  666.           OriBytes=OriBytes+OriBytes.i
  667.         end
  668.   
  669.         /*pasa a grafica BBS que mas escriben*/
  670.         if open('source','ram:Mensaje.txt','A') then do
  671.           b=writeln('source','')
  672.           b=writeln('source','')
  673.           b=writeln('source',copies('=',60))
  674.           b=writeln('source',center(idioma.29' ['Tag.x']',60))
  675.           b=writeln('source',copies('=',60))
  676.           b=writeln('source',left(idioma.30,11)||left(idioma.31,11)||'%%   'idioma.32)
  677.           b=writeln('source',copies('-',60))
  678.           max=0;semtot=0;porcien.=0
  679.           do i=1 to oris
  680.             porNum=trunc(OriNum.i*100/MsgTotal,2)
  681.             porBytes=trunc(OriBytes.i*100/Oribytes,2)
  682.             b=writeln('source',left(OriNodo.i,11)||right(OriNum.i,7)' 'right(porNum,6)'% 'copies('*',trunc(int(33*pornum/100+.5))))
  683.             b=writeln('source',copies(' ',11)||right(OriBytes.i,7)' 'right(porBytes,6)'% 'copies('*',trunc(int(33*porBytes/100+.5))))
  684.             if i<oris then b=writeln('source','')
  685.          end
  686.           b=writeln('source',copies('=',60))
  687.         call close 'source'
  688.         end
  689.  
  690.       /*Manda Mensaje*/
  691.       address 'MAILMANAGER'
  692.       mm_getsysop sysop
  693.       address command
  694.       'rx MM:Rexx/MM_SendMsg.rexx 'tag.x', 'sysop', , All, , ram:Mensaje.txt, EXPORT, 'idioma.33' ['Tag.x'] 'date()', 'idioma.1' ['Tag.x']'
  695.       /*guarda datos*/
  696.       if open('source','MM:config/MM_EstadisEcos.cfg','W') then do
  697.         do z=1 to totalcfg
  698.           if upper(word(totalcfg.z,1))="#AREA" then do
  699.             do zz=1 to ecos
  700.               if upper(word(totalcfg.z,2))=tag.zz then do
  701.                 b=writeln('source',"#AREA"d2c(9)||Tag.zz||d2c(9)leng.zz||d2c(9)||topedias.zz||d2c(9)||control.zz)
  702.               end
  703.             end
  704.           end
  705.           else do
  706.             b=writeln('source',totalcfg.z)
  707.           end
  708.         end
  709.       call close 'source'
  710.       end
  711.      address 'MAILMANAGER'
  712.       CALL WriteLog('   \ Fin 'Tag.x)
  713.       log=date('e')||" "||time()||"    \ Fin "||Tag.x
  714.       call logs
  715.     end
  716.     else do
  717.       address 'MAILMANAGER'
  718.       MM.LogLevel=2
  719.       CALL WriteLog(' * 'Tag.x ' - Paso')
  720.       address command
  721.       log=date('e')||" "||time()||"  * "||Tag.x||" - Paso"
  722.       call logs
  723.       encuentra=0
  724.     end
  725.   end
  726.   if RC=4 then do
  727.     address 'MAILMANAGER'
  728.     CALL WriteLog(' * 'Tag.x '- Tag Incorrecto!')
  729.     log=date('e')||" "||time()||"  * "||Tag.x||" - Tag Incorrecto!"
  730.     call logs
  731.     encuentra=0
  732.   end
  733. end
  734.  
  735.  
  736. /*borra ficheros temporales en ram:*/
  737. if exists('ram:mensaje.txt')=1 then do
  738.   call delete('ram:mensaje.txt')
  739. end
  740. if exists('ram:Temp0.txt')=1 then do
  741.   call delete('ram:Temp0.txt')
  742. end
  743. if exists('ram:Temp1.txt')=1 then do
  744.   call delete('ram:Temp1.txt')
  745. end
  746.  
  747.  
  748. address 'MAILMANAGER'
  749. r=time('e');h=trunc(int(r/60/60));m=trunc(int(r/60));s=trunc(int(r//60))
  750. tim=right(h,2,'0')||":"||right(m,2,'0')||":"||right(s,2,'0')
  751. CALL WriteLog('   Procesado en 'tim)
  752. CALL WriteLog('MM_EstadisEcos.rexx - Salida')
  753. log=date('e')||" "||time()||"    Procesado en "||tim
  754. call logs
  755. log=date('e')||" "||time()||" MM_EstadisEcos.rexx - Salida"
  756. call logs
  757. exit
  758.  
  759.  
  760. WriteLog: PROCEDURE EXPOSE MM.
  761. PARSE ARG Testo
  762. address 'MAILMANAGER'
  763. MM_WriteLog 'Testo' MM.LogLevel
  764. address command
  765. RETURN
  766.  
  767.  
  768. /*========================================================================*/
  769. /*Lee Textos Idioma MM_EstadisEcos.xxx*/
  770. idioma:
  771.   if exists('MM:config/MM_EstadisEcos.'leng.x)=0 then do
  772.     fallo="Error! No encuentro MM:config/MM_EstadisEcos."||leng.x
  773.     call fallos
  774.     exit
  775.   end
  776.   lin=34 /* numero de lineas idioma */
  777.   if open('source','MM:config/MM_EstadisEcos.'leng.x) then do
  778.     do z=1 to lin
  779.       idioma.z=readln('source')
  780.     end
  781.   call close 'source'
  782.   end
  783. return ok
  784.  
  785.  
  786. /*log*/
  787. logs:
  788.   if open('source1',pathlog,'A') then do
  789.     b=writeln('source1',log)
  790.   call close 'source1'
  791.   end
  792. return ok
  793.  
  794.  
  795. /*errores*/
  796. fallos:
  797.   address 'MAILMANAGER'
  798.   CALL WriteLog(fallo)
  799.   log=date('e')||" "||time()||" "||fallo
  800.   call logs
  801. return ok
  802.  
  803. /*========================================================================*/
  804. break_c:
  805. exit
  806.  
  807.  
  808. halt:
  809. syntax:
  810. error:
  811. ioerr:
  812. syntax:
  813.   parse source cadena
  814.   name=upper(result)
  815.   fallo="ERROR! Linea: "||sigl||" Error: "||rc||" "||errortext(rc)
  816.   call fallos
  817.   fallo="Avisa al Autor!"
  818.   call fallos
  819. exit
  820.